from io import StringIO
#~ from
from subprocess import Popen, PIPE,check_output
string='''
@startuml
test-->test1

@enduml

'''

try:
    p = Popen(['plantuml','-tsvg','-p'],  stdout=PIPE, stdin=PIPE, stderr=PIPE)
    out, err = p.communicate(input=bytearray(string,'utf-8'))
except Exception as exc:
    raise Exception('Failed to run plantuml: %s' % exc)
with open('t.png','wb' ) as f:
    f.write(out)
